<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>粮油集团办公自动化协作平台</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" id="txlz7"/>
		
	<link rel="stylesheet" type="text/css" href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" />
		
	
	<%
		User user = (User)session.getAttribute("user");
		String group_id = (String)request.getAttribute("group_id");
		String moduleType = (String)request.getAttribute("moduleType");
		String userSort = (String)request.getAttribute("userSort");
	 %>
	 <style>
			 td {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000;
			}
			th {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000;
			}
	 .GroupDiv {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1003;
			overflow: auto;
		}
		.ErrorDiv {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.black_overlays{
			display: block;
			position: absolute;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: #C1EBFC;
			z-index:1002;
			-moz-opacity: 0.8;
			opacity:.80;
			filter: alpha(opacity=30);
		}
		
		.shaodeng {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		
		.lan01{
background: url(<%=basePath%>images/lanbg01.gif) no-repeat 0 0; width:6px; height:24px;} 
.lan02{
background: url(<%=basePath%>images/lanbg02.gif) repeat-x; width:99%; height:24px;}            
.lan03{
background: url(<%=basePath%>images/lanbg03.gif) no-repeat; width:8px; height:24px;}             
.cha{
padding-top:3px;}
	 </style>
	 <script type='text/javascript' src='<%=basePath%>dwr/interface/AddressListGroupBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
	
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/ext-all-debug.js"></script>
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/states.js"></script>
		
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
	
	<script type="text/javascript" src="<%=basePath %>js/My97DatePicker/WdatePicker.js"></script>
	
<script type="text/javascript">
	function checkAllTextValid(form)  
	{  
	    //记录不含引号的文本框数量  
		var resultTag = 0;  
		//记录所有text文本框数量  
		var flag = 0;  
		for(var i = 0; i < form.elements.length; i ++)  
		{  
		 if(form.elements[i].type=="text")  
		 {  
		     flag = flag + 1;  
		  //此处填写所要过滤的特殊符号  
		  //注意：修改####处的字符，其它部分不许修改.  
		  //if(/^[^####]*$/.test(form.elements[i].value))  
		  if(/^[^\|"'<>]*$/.test(form.elements[i].value)) resultTag = resultTag+1;  
		  else form.elements[i].select();  
		 }  
		}
		//如果含引号的文本框等于全部文本框的值，则校验通过  
		if(resultTag == flag) return true;  
		else 
		{  
		 Ext.MessageBox.alert('提示框',"<nobr>文本框中不能含有<br/> 1 单引号: ' <br/> 2 双引号: \" <br/> 3 竖  杠: | <br/> 4 尖角号: < > <br/><br/>请检查输入！</nobr>");  
		 return false;  
		}  
	}
	
	function huifu(){
		document.getElementById("shaodeng").style.display = "none";
		document.getElementById("blackdiv").style.display = "none";
	}
		
	function getGroup(){
		AddressListGroupBo.getGroup(<%=user.getUser_id() %>,<%=moduleType %>,Group);
	}
	
	function Group(fu){
		var Grouphtml = '<table width="100%" class="researchtab"><tr>';
			var i = 0;
			for(var a=0;a<fu.length;a=a+3){
				if(fu[a] == '<%=group_id %>'){
					Grouphtml += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'" checked=\"checked\" onclick=\"newGroupName(this)\"/>'+fu[a+1]+'</td>';
					document.getElementById('newGroupName').value = fu[a+1];
					document.getElementById('groupName').value = fu[a+1];
					document.form1.groupid.value = fu[a];
				}else if(fu[a+1].length>=5){
					Grouphtml += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'" onclick="newGroupName(this)"/><a title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,6)+'</a></td>';
				}else{
					Grouphtml += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'" onclick="newGroupName(this)"/>'+fu[a+1]+'</td>';
				}
				i++;
				if(i%3 == 0){
					Grouphtml += '</tr><tr>';
				}else if(a == fu.length){
					Grouphtml += '</tr></table>';
				}
			}
			var GroupNameDiv = document.getElementById("GroupNameDiv");
			GroupNameDiv.innerHTML = Grouphtml;
			huifu();
	}
	
	function xianshiGroup(){
		document.getElementById("GroupDiv").style.top = document.body.clientHeight/6;
		document.getElementById("GroupDiv").style.left = document.body.clientWidth/8;
		document.getElementById("blackdiv").style.display = "block";
		document.getElementById("GroupDiv").style.display = "block";
	}
	
	function xiaoshiGroup(){
		document.getElementById("blackdiv").style.display = "none";
		document.getElementById("GroupDiv").style.display = "none";
		document.getElementById('groupidradio').checked = '';
		var oEle = document.getElementsByName('groupidradio');
		if(oEle.length>0){
			for(var i = 0 ;i<oEle.length;i++){
			      if(oEle[i].checked = 'true')oEle[i].checked = '';
			  }
		}
	}
	
	function newGroupName(str){
		document.getElementById('newGroupName').value = str.alt;
		document.form1.groupid.value = str.value;
	}
	
	function overGroup(){
		document.getElementById('groupName').value = document.getElementById('newGroupName').value;
		document.getElementById('newGroupName').value = '';
		xiaoshiGroup();
	}
	
	function submitform1(){
		if(document.getElementById('groupName').value=='' || document.getElementById('groupName').value==null){
			Ext.MessageBox.alert('提示框','<nobr>请选择所在组</nobr>');
		}else{
		if(document.getElementById('userName').value == null || document.getElementById('userName').value == ''){
			Ext.MessageBox.alert('提示框','<nobr>请填入联系人姓名</nobr>');
		}else{
			if(checkAllTextValid(document.form1))document.form1.submit();
		}
		}
	}
	
	function shaodeng(){
		document.getElementById("shaodeng").style.top = document.body.clientHeight/3;
		document.getElementById("shaodeng").style.left = document.body.clientWidth/3;
		document.getElementById("shaodeng").style.display = "block";
	}
		
	function yanhomePhone(){
		var zhengze = /^[0-9\-]{0,20}$/;
		if(!zhengze.exec(document.getElementById('homePhone').value) && document.getElementById('homePhone').value!=''){
			Ext.MessageBox.alert('提示框','<nobr>家庭电话输入只能为数字、-,且最多20位</nobr>');
			document.getElementById('homePhone').value = '';
			return false;
		}
	}
	
	function yancompanyPhone(){
		var zhengze = /^[0-9\-]{0,20}$/;
		if(!zhengze.exec(document.getElementById('companyPhone').value) && document.getElementById('companyPhone').value!=''){
			Ext.MessageBox.alert('提示框','<nobr>公司电话输入只能为数字、-,且最多20位</nobr>');
			document.getElementById('companyPhone').value = '';
		}
	}
	
	function yancompanyFax(){
		var zhengze = /^[0-9\-]{0,20}$/;
		if(!zhengze.exec(document.getElementById('companyFax').value) && document.getElementById('companyFax').value!=''){
			Ext.MessageBox.alert('提示框','<nobr>公司传真输入只能为数字、-,且最多20位</nobr>');
			document.getElementById('companyFax').value = '';
		}
	}
	
	function yanNumLength(id,name,length){
		var str = document.getElementById(id).value;
		if(str!=''){
		if(!isNaN(str)){
			if(str.length > length){
				Ext.MessageBox.alert('提示框','<nobr>'+name+'输入只能为数字且最多'+length+'位</nobr>');
				document.getElementById(id).value = '';
			}
		}else{
			Ext.MessageBox.alert('提示框','<nobr>'+name+'输入只能为数字且最多'+length+'位</nobr>');
			document.getElementById(id).value = '';
		}
		}
	}
	function yanlength(id,name,lenth){
		var str = document.getElementById(id).value;
		if(str!=''){
		if(str.length > lenth){
			Ext.MessageBox.alert('提示框','<nobr>'+name+'的长度只能为'+lenth+'以内</nobr>');
			document.getElementById(id).value = '';
		}
		}
	}
	
	function yanemail(){
		var str = document.getElementById('email').value;
		if(!checkMail(str) && str!=''){
			Ext.MessageBox.alert('提示框','<nobr>E-Mail格式不正确</nobr>');
			document.getElementById('email').value = '';
			return false;
		}
		return true;
	}
	
	function closeErrorDiv(){
		document.getElementById("blackdiv").style.display = "none";
		document.getElementById("ErrorDiv").style.display = "none";
	}
	
	function xianshiErrorDiv(){
		document.getElementById("ErrorDiv").style.top = document.body.clientHeight/4;
		document.getElementById("ErrorDiv").style.left = document.body.clientWidth/8;
		document.getElementById("blackdiv").style.display = "block";
		document.getElementById("ErrorDiv").style.display = "block";
	}

/**
 * @param eml {String}
 */
function checkMail(eml){
	if(!/^[\.\w]([(\/)(\-)(\+).\w])*@([(\-)\w]{1,64}\.){1,7}[(\-)\w]{1,64}$/.test(eml)){
		return false;
	}else{
		if(eml && eml != "" && (eml.indexOf("@") != -1)){
			var p = eml.indexOf("@");
			var name = eml.substring(0, p);
			if(name.length >64 || eml.length > 256){
				return false;
			}else{
				return true;
			}
		}
	}
	return false;
}
window.onload = function(){
	document.getElementById("right").style.height = document.body.clientHeight;
	document.getElementById("zongdiv").style.height = document.body.clientHeight-50;
	getGroup();
	var tb = new Ext.Toolbar(
		{
			height:25
		}
	);

    tb.render('menu');
	tb.add(
    {
            text:'确定',
            iconCls: 'daohang',
        	handler: function(){
        		submitform1();
			}
    },
    {
            text:'返回',
            iconCls: 'daohang',
        	handler: function(){
        		location.href="<%=basePath%>tjsinfo/tjsoa/addresslist/loginAddressList.do?moduleType=<%=moduleType %>";
			}
    }
    );
	tb.addFill();
    tb.addText('<img id="windowResize" src="<%=basePath%>images/m_icon05.gif;"><a style="font-weight:bold; color:black;line-height: 22px;">新建联系人</a>&nbsp;&nbsp;&nbsp;');
}
</script>
  </head>
  
  <body>
  <div id="right" style="width: 99%;">
      <div id="menu" style="padding-top:4px;"></div>
      <div class="contact_content" id="zongdiv">
      <form action="<%=basePath %>tjsinfo/tjsoa/addresslist/insertAddressListUser.do" name="form1" method="post">
      <input type="hidden" name="groupid" id="groupid"/>
      <input type="hidden" name="yuangroupid" id="yuangroupid" value="<%=group_id %>"/>
      <input type="hidden" name="moduleType" id="moduleType" value="<%=moduleType %>"/>
         <table width="99%" height="90%" border="0" cellspacing="0" cellpadding="0" align="center">
         	<tr>
         		<td colspan="3">&nbsp;</td>
         	</tr>
              <tr>
                <td width="10%" align="center" valign="middle"><img src="<%=basePath%>images/basicicon.gif" /></td>
                <td colspan="2"><table width="90%" border="0" cellspacing="0" cellpadding="0" align="left">
                                      <tr>
                                        <td width="50%">姓&nbsp;&nbsp;&nbsp;&nbsp;名:
                <input id="userName" name="userName" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('userName','联系人姓名',50)"/></td>
                                        <td width="50%">手&nbsp;&nbsp;&nbsp;&nbsp;机:
                <input id="mobile" name="mobile" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanNumLength('mobile','手机',20)"/></td>
                                      </tr>
                                      <tr>
                                        <td width="50%" colspan="2">E-&nbsp;mail:&nbsp;
                <input id="email" name="email" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onblur="yanemail()"/></td>
                                      </tr>
                                </table>              </td>
              </tr>
              <tr>
                <td colspan="3" height="2" background="<%=basePath%>images/line02.gif"></td>
              </tr>
              <tr>
                <td width="10%" align="center" valign="middle"><img src="images/houseicon.gif" /></td>
                <td colspan="2"> 
                            <table width="90%" border="0" cellspacing="0" cellpadding="0" align="left">
                                      <tr>
                                        <td width="50%">住宅地址:
                <input id="homeAddress" name="homeAddress" type="text" size="41" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('homeAddress','住宅地址',75)"/></td>
                                        <td width="50%">住宅电话:
                <input id="homePhone" name="homePhone" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanhomePhone()"/></td>
                                      </tr>
                                      <tr>
                                        <td width="50%" colspan="2">住宅邮编:
                <input id="homePostal" name="homePostal" type="text" size="41" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanNumLength('homePostal','住宅邮编',10)"/></td>
                                      </tr>
                             </table>                </td>
              </tr>
              <tr>
                <td colspan="3" height="2" background="<%=basePath%>images/line02.gif"></td>
              </tr>
              <tr>
                <td width="10%" align="center" valign="middle"><img src="<%=basePath%>images/contacticon.gif" /></td>
                <td colspan="2">
                          <table width="90%" border="0" cellspacing="0" cellpadding="0" align="left">
                                      <tr>
                                        <td width="50%">工作单位:
                <input id="company" name="company" type="text" size="41" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('company','工作单位',50)"/></td>
                                        <td width="50%">部&nbsp;&nbsp;&nbsp;&nbsp;门:
                <input id="sector" name="sector" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('sector','部门',50)"/></td>
                                      </tr>
                                      <tr>
                                        <td width="50%">职&nbsp;&nbsp;&nbsp;&nbsp;务:
                <input id="duty" name="duty" type="text" size="41" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('duty','职务',25)"/></td>
                                        <td width="50%">电&nbsp;&nbsp;&nbsp;&nbsp;话:
                <input id="companyPhone" name="companyPhone" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yancompanyPhone()"/></td>
                                      </tr>
                                      <tr>
                                        <td width="50%">传&nbsp;&nbsp;&nbsp;&nbsp;真:
                <input id="companyFax" name="companyFax" type="text" size="41" style="border:1px #ddd solid;background:#F4F4F4" onchange="yancompanyFax()"/></td>
                                        <td width="50%">地&nbsp;&nbsp;&nbsp;&nbsp;址:
                <input id="companyAddress" name="companyAddress" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('companyAddress','公司地址',75)"/></td>
                                      </tr>
                                      <tr>
                                        <td width="50%" colspan="2">邮&nbsp;&nbsp;&nbsp;&nbsp;编:
                <input id="companyPostal" name="companyPostal" type="text" size="41" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanNumLength('companyPostal','公司邮编',10)"/></td>
                                      </tr>
                          </table>                </td>
              </tr>
              <tr>
                <td colspan="3" height="2" background="<%=basePath%>images/line02.gif"></td>
              </tr>
              <tr>
                <td width="10%" align="center" valign="middle"><img src="<%=basePath%>images/othericon.gif" /></td>
                <td colspan="2">
                         <table width="90%" border="0" cellspacing="0" cellpadding="0" align="left">
                                      <tr>
                                        <tr>
                                      	<td width="50%" colspan="2">
                                      		<table width="361" border="0" cellspacing="0" cellpadding="0" class="tabbb">
    <tr>
        <td width="66" valign="top">生&nbsp;&nbsp;&nbsp;&nbsp;日: </td>
        <td width="295">
        	<input name="birthday" id="birthday" type="text" class="Wdate" onclick="WdatePicker()"/>
          </td>
          </tr>
          </table>
                                      	</td>
                                        <td width="50%">QQ&nbsp;&nbsp;账号:
                <input id="qq" name="qq" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanNumLength('qq','QQ号',12)"/></td>
                                      </tr>
                                      <tr>
                                        <td width="50%" colspan="2">MSN&nbsp;账号:
                <input id="msn" name="msn" type="text" size="41" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('msn','MSN帐号',50)"/></td>
                                        <td width="50%"> Blog地址:
                <input id="blog" name="blog" type="text" size="40" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('blog','BLOG',50)"/></td>
                                      </tr>
                                      <%
                                      	if(moduleType.equals("0")){
                                       %>
                                      <tr>
                                        <td width="100%" colspan="4">排&nbsp;&nbsp;&nbsp;&nbsp;序:
                <input id="userSort" name="userSort" type="text" size="41" value="<%=userSort %>" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanNumLength('userSort','排序',10)" readonly="readonly"/></td>
                                      </tr>
                                      <%
                                      	}
                                       %>
                                      <tr>
                                        <td width="50%" colspan="3" >
                                          <table width="625" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                                <td width="86" valign="top">备&nbsp;&nbsp;&nbsp;&nbsp;注: </td>
                                                <td width="481" align="left">
         <textarea name="remarks" id="remarks" cols="78" rows="4" style="border:1px #ddd solid;background:#F4F4F4" onchange="yanlength('remarks','备注',150)"></textarea>                                                </td>
                                            </tr>
                                          </table>
                                         </td>
                                      </tr>
                         </table></td>
              </tr>
              <tr>
                <td colspan="3" height="2" background="<%=basePath%>images/line02.gif"></td>
              </tr>
              <tr>
                <td width="10%" align="center" valign="middle"><img src="<%=basePath%>images/groupicon01.gif" /></td>
                <td colspan="2">
                         <table width="60%" border="0" cellspacing="0" cellpadding="0" class="tabbbb" align="left">
<tr>
                                        <td width="20px">
                 <input name="groupName" type="text" size="40" readonly="readonly" style="border:1px #ddd solid;background:#F4F4F4"/>                                        </td>
                  <td width="68%"><a href="javaScript:xianshiGroup()"><img src="<%=basePath%>images/icon100.gif" /></a>                                       </td>
                           </tr>  
                         </table>                </td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td colspan="2">&nbsp;</td>
              </tr>
         </table>
        </form>
  </div>
</div>
<%-- 隐藏层 
	GroupDiv -- 选择组时隐藏层

	blackdiv -- 周围颜色层

--%>
    <div id="GroupDiv" class="GroupDiv">
    <table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td background="images/small_07.gif" height="24" align="left">
                 <table width="99%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="8%" style="padding-left:15px; padding-top:3px;"><img src="images/icon_07.gif" /></td>
                        <td width="86%" style="color:#FFFFFF; font-weight:bold;padding-top:3px">选择所属组</td>
                        <td width="6%" valign="bottom">
							<div class="cha">
								<img src="<%=basePath%>images/cha.gif"
									onclick="javaScript:xiaoshiGroup();"
											style="cursor: hand" />
							</div>
						</td>
                      </tr>
                    </table>
                 </td>
               </tr>
               <tr>
                 <td align="center" class="zz">
                     <table width="90%" height="180" border="0" cellspacing="0" cellpadding="0" >
                      <tr><td colspan="3" align="left">
                       <div id="GroupNameDiv">
                       </div>
                      </td>
                      </tr>
                      <tr>
                        <td width="18%">&nbsp;</td>
                        <td width="12%">所属组：</td>
                        <td width="70%" align="left"><input name="newGroupName" id="newGroupName" type="text" size="30" class="textinput" readonly="readonly"/></td>
                      </tr>
                      <tr>
                        <td colspan="3">&nbsp;</td>
                      </tr>
                      <tr><td colspan="3" style="border-top:1px #CFCFD1 solid">&nbsp;</td></tr>
                      <tr>
                        <td colspan="3" align="center"><a href="javaScript:overGroup();"><img src="<%=basePath%>images/qd.gif" /></a>&nbsp;&nbsp;
                        <a href="javaScript:xiaoshiGroup();"><img src="<%=basePath%>images/qx.gif" />
                        </td>
                      </tr>
                      <tr>
                        <td colspan="3">&nbsp;</td>
                     </tr>
                    </table>
</td>
</tr>
</table>
</div>
<div class="shaodeng" id="shaodeng">
	<table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td height="24" align="left">
                 <b>请求正在处理中,请稍候....</b>
                 </td>
               </tr>
             </table>
</div>
<div id="blackdiv" class="black_overlays">
	<iframe style="width:100%;height:100%;filter:alpha(opacity=0);-moz-opacity:0"></iframe>
</div>
  </body>
</html>
